package com.youchuang.action.user;

import javax.annotation.Resource;

import org.apache.log4j.Logger;
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.ParentPackage;
import org.apache.struts2.convention.annotation.Result;

import com.youchuang.action.BaseAction;
import com.youchuang.bean.User;
import com.youchuang.common.Constant;
import com.youchuang.service.UserService;

/**
 * 登录
 * 
 * @author Administrator
 *
 */
@Namespace(value = "/user")
@ParentPackage("shopping-default")
public class LoginAction extends BaseAction {
	private Logger logger = Logger.getLogger(LoginAction.class.getSimpleName());
	private User user;
	
	@Resource
	private UserService userService;

	@Action(value = "login", results = { @Result(name = Constant.LOGIN, location = "/WEB-INF/jsp/user/login_form.jsp"),
			@Result(name = Constant.VERIFY, location = "/WEB-INF/jsp/user/verify_form.jsp"),
			@Result(name = Constant.SUCCESS, type = "redirectAction", params = { "namespace", "/", "actionName",
					"mainAction" }) })
	public String execute() {
		logger.info("excetion is execute");

		return userService.loginUser(user);
	}

	public User getUser() {
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}

}
